<?php
/**
 * 管理员
 * User: cxm
 */

namespace App\Http\Resources\Admin;

use Illuminate\Http\Resources\Json\JsonResource as Resource;

class AdminUserResource extends Resource
{

    public function toArray($request)
    {
        $data = [
            "id"    => $this->id,
            "username" => $this->username,
            "avatar" => isset($this->file->path) ? $this->file->path : '',
            "phone" => $this->mobile,
            "name" => $this->name,
            "user_type" => $this->user_type,
            "status"    => $this->status,
            'role_id'   => isset($this->user_role->role)  ? $this->user_role->role->id : '',
            "role_name" => isset($this->user_role->role) ? $this->user_role->role->name : '',
            "created_at" => "{$this->created_at}",
        ];
        return $data;
    }
}
